angular.module('wf-utils')
.factory('userData', ($localStorage,wfAlert,$state,authorityManage) ->
    getToken: -> $localStorage['token']
    setToken: (token) -> $localStorage['token']=token
    setAccount:(accountId)-> $localStorage['accountId']=accountId
    getAccount:-> $localStorage['accountId']
    setStore:(store)-> $localStorage['accountStore']=store
    getStore:-> $localStorage['accountStore']
    getUser: -> angular.copy $localStorage['user']
    login:(overdue)->
        if overdue
            wfAlert.toastInfo('登录信息过期，请重新登录')
        $localStorage.$reset()
        authorityManage.clear()
        $state.go 'login'
    setUser: (data) ->
        $localStorage['user']=data
    reset: ->
        $localStorage['user']=null
        $localStorage['token']=null
)